window.addEventListener('load', function () {

    // index.html  start-----------------------------
    // top   start
    var link = this.document.querySelector(".link");
    var link_lis = link.children.length;;
    console.log(link_lis);
    for (var i = 0; i < link_lis; i++) {
        link.children[i].addEventListener('mouseover', function () {

            this.style.backgroundColor = '#ffff00';
        })

        link.children[i].addEventListener('mouseout', function () {

            this.style.backgroundColor = '';
        })
    }
    // top   end


    // 轮播图start
    var slideIndex = 0;
    var prev = this.document.querySelector('.prev');
    var next = this.document.querySelector('.next');
    var slider = document.querySelector('.slider');


    function handlemouseover() {
        clearInterval(timer);
        prev.style.display = 'block';
        next.style.display = 'block';
    }


    slider.addEventListener('mouseover', handlemouseover)

    slider.addEventListener('mouseout', function () {
        timer = setInterval(function () {
            nextSlide();
        }, 2000);
        prev.style.display = 'none';
        next.style.display = 'none';
    })



    function showSlide(n) {
        var slides = document.getElementsByClassName("slide");
        if (n >= slides.length) {
            slideIndex = 0;
        }
        if (n < 0) {
            slideIndex = slides.length - 1;
        }
        for (var i = 0; i < slides.length; i++) {
            slides[i].style.display = "none";
        }
        slides[slideIndex].style.display = "block";
    }

    function nextSlide() {
        slideIndex++;
        showSlide(slideIndex);
    }

    function prevSlide() {
        slideIndex--;
        showSlide(slideIndex);
    }

    var timer = setInterval(function () {
        nextSlide();
    }, 900);

    prev.addEventListener('click', function () {
        clearInterval('timer');
        prevSlide()
    })
    next.addEventListener('click', function () {
        clearInterval('timer');
        nextSlide();
    })
    // ====================================





    var mySwiper = new Swiper('.mySwiper', {
        autoplay: {
            delay: 1000, // 自动轮播间隔时间，单位为毫秒
        },
    });





    // 轮播图end

    // 返回顶部statr
    function animate(obj, target, callback) {
        // 问题：不断点击按钮 开启多个定时器  速度加快
        // 解决方法：清除以前的定时器
        clearInterval(obj.timer)
        // 给不同元素记录不同的定时器
        obj.timer = setInterval(function () {
            // 步长值写到定时器里面
            var step = (target - window.pageYOffset) / 10;
            step = step > 0 ? Math.ceil(step) : Math.floor(step);
            // 目标值等于边距值之后 清除定时器 如果来回设置边距 不要添加比较符号
            if (window.pageYOffset == target) {
                // 停止动画
                // 大于移动距离 清楚定时器
                clearInterval(obj.timer);
                if (callback) {
                    callback();
                }
            } else {
                // 移动的值 改为一个慢慢变小的值    步长公式：(目标值-现在的位置)/10
                // obj.style.top = window.pageYOffset + step + 'px';
                window.scroll(0, window.pageYOffset + step)
            }
        }, 15);
    }






    var goback = document.querySelector(".goback");
    var slider = document.querySelector(".slider");
    var slidertop = slider.offsetTop + 200;
    console.log(slidertop);
    document.addEventListener("scroll", function () {
        if (window.pageYOffset >= slidertop) {
            goback.style.display = 'block'
        } else {
            goback.style.display = 'none'
        }
    })
    goback.addEventListener('click', function () {
        animate(window, 0);
    })


    // 返回顶部end




    // index.html  start----------------------------



    // check  start
    var bluse = true;
    var c_on = this.document.querySelector('.c-on');
    var c_off = this.document.querySelector('.c-off');
    var notification = this.document.querySelector('.notification');
    var notification_h4 = notification.querySelector('h4');


    c_on.addEventListener('mouseover', function () {
        if (bluse) {
            this.style.marginTop = 5 + 'px';
            this.style.boxShadow = '3px 3px 10px rgba(0, 0, 0, 0.5)';
        }
        bluse = false;

    })


    c_on.addEventListener('mouseout', function () {
        if (!bluse) {
            this.style.marginTop = '';
            this.style.boxShadow = '';
        }
        bluse = true;
    })


    c_off.addEventListener('mouseover', function () {
        if (bluse) {
            this.style.marginTop = 5 + 'px';
            this.style.boxShadow = '3px 3px 10px rgba(0, 0, 0, 0.5)';
            bluse = false;
        }
        bluse = false;
    })


    c_off.addEventListener('mouseout', function () {
        if (!bluse) {
            this.style.marginTop = '';
            this.style.boxShadow = '';
        }
        bluse = true;
    })



    notification_h4.addEventListener('mouseover', function () {
        if (bluse) {
            this.style.marginTop = 5 + 'px';
            this.style.boxShadow = '3px 3px 10px rgba(0, 0, 0, 0.5)';
            bluse = false;
        }
        bluse = false;
    })


    notification_h4.addEventListener('mouseout', function () {
        if (!bluse) {
            this.style.marginTop = '';
            this.style.boxShadow = '';
        }
        bluse = true;
    })
    // check  end


    var downloadList = document.querySelector('.download_list');
    var lis = downloadList.getElementsByTagName('li');
    for (var i = 0; i < lis.length; i++) {
        lis[i].onmouseover = function () {
            this.style.width = '118%'; // 鼠标移入时，width变小
        }
        lis[i].onmouseout = function () {
            this.style.width = '100%'; // 鼠标移出时，width恢复原值
        }
    }














    // regesiter start














    // regesiter end





















})
